package com.bioroadlab.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.bioroadlab.pojo.DiseaseCategory;

@Repository
public class DiseaseCategoryDao extends BaseDao<DiseaseCategory, Integer> {

	public void updateDiseaseCategory(DiseaseCategory diseaseCategory) {
		getSession().update(diseaseCategory);
	}

	public void saveDiseaseCategory(DiseaseCategory diseaseCategory) {
		String sql = "insert into disease_category (`name`) value(name=:name)";
		Query query = getSession().createSQLQuery(sql);
		query.setParameter("name", diseaseCategory.getName());
		query.executeUpdate();
	}

	public List<DiseaseCategory> findAll() {
		String hql = "from DiseaseCategory";
		Query query = getSession().createQuery(hql);
		@SuppressWarnings("unchecked")
		List<DiseaseCategory> list = ((List<DiseaseCategory>) query.list());
		return list;
	}

}
